<template>
	<zkView ref="zkView" v-slot:uContainer>
		<view class="container">
			<view class="list" v-if="type===1&&(userInfo.role===2||userInfo.role===9)">
				<view class="couponItem bgColor1">
					<view class="itemLeft">
						<rich-text :nodes="formatZhe(90)" />
					</view>
					<view class="itemMid">
						<text>会员专属9折优惠</text>
						<text>全场通用</text>
					</view>
					<view class="itemRight">
						<text>可使用</text>
					</view>
				</view>
			</view>
			<view class="list" v-if="couponList&&couponList.length">
				<view v-if="type===1&&(userInfo.role===2||userInfo.role===9)" class="couponItem bgColor1">
					<view class="itemLeft">
						<rich-text :nodes="formatZhe(90)" />
					</view>
					<view class="itemMid">
						<text>9折优惠</text>
						<text>全场通用</text>
					</view>
					<view class="itemRight">
						<text>可使用</text>
					</view>
				</view>
				<view :class="`couponItem ${item.type===1?'bgColor1':'bgColor2'}`" v-for="item in couponList" :key="item._id">
					<view class="itemLeft">
						<rich-text v-if="item.type===1" :nodes="formatZhe(item.couponInfo.discount)" />
						<rich-text v-if="item.type===2" :nodes="formatPrice(item.couponInfo.discount,2)" />
					</view>
					<view class="itemMid">
						<text v-if="item.type===1">{{item.couponInfo.usage_limit}}折优惠</text>
						<text
							v-if="item.type===2">满{{formatPrice(item.couponInfo.usage_limit)}}立减{{formatPrice(item.couponInfo.discount)}}</text>
						<text>全场通用</text>
					</view>
					<view class="itemRight">
						<text v-if="item.is_used">已使用</text>
						<text v-else-if="item.is_expired">已过期</text>
						<text v-else>可使用</text>
					</view>
				</view>
			</view>

			<view class="noData" v-else-if="userInfo.role===1">
				<image mode="widthFix" src="/static/empty.png"></image>
				<text>暂无优惠券</text>
			</view>
		</view>
	</zkView>
</template>

<script>
	import indexJs from './index.js';
	import mixins from '@/common/mixins.js';
	export default {
		components: {},
		mixins: [mixins],
		...indexJs
	};
</script>

<style lang="scss" scoped>
	@import './index.scss';
</style>